
import request from '@/utils/request'

const api = {
    getContractLaborList: '/v1/contract/labor/company/page/list', // 获取合同分页列表
    createLaborContract: '/v1/contract/labor/company/create', // 劳务公司上传合同
    createAwardContract: '/v1/contract/award/create', // 创建、修改推广合同
    getAwardContractDetail: '/v1/contract/award/detail', // 获取推广佣金合同详情
    changeLaborContractState: '/v1/contract/labor/company/state/change', // 劳务公司合同状态切换
    getContractCustomerList: '/v1/contract/labor/company/choose/customer/list/', // 获取当前合同的客户列表
    chooseLaborContractCustomer: '/v1/contract/labor/company/customer/choose', // 设置合同所属客户
    getBusinessCustomerList: '/v1/contract/customer/business/page/list', // 获取客户业务合同列表
    createBusinessContract: '/v1/contract/customer/business/create', // 客户业务创建合同
    deleteBusinessContract: '/v1/contract/customer/business/delete/', // 删除客户业务合同
    getContractByCustomer: '/v1/contract/customer/list/', // 获取客户下的合同列表
    uploadUserContract: '/v1/project/user/contract/upload', // 上传用户合同
}

// 获取合同分页列表
export function getContractLaborList (parameter) {
    return request({
        url: api.getContractLaborList,
        method: 'get',
        headers: {
            'name':'getContractLaborList',
        },
        params: parameter
    })
}

// 劳务公司上传合同
export function createLaborContract (parameter) {
    return request({
        url: api.createLaborContract,
        method: 'post',
        headers: {
            'name':'createLaborContract',
        },
        data: parameter
    })
}

// 劳务公司合同状态切换
export function changeLaborContractState (parameter) {
    return request({
        url: api.changeLaborContractState,
        method: 'post',
        headers: {
            'name':'changeLaborContractState',
        },
        data: parameter
    })
}

// 创建、修改推广合同
export function createAwardContract (parameter) {
    return request({
        url: api.createAwardContract,
        method: 'post',
        headers: {
            'name':'createAwardContract',
        },
        data: parameter
    })
}

// 获取推广佣金合同详情
export function getAwardContractDetail (parameter) {
    return request({
        url: api.getAwardContractDetail,
        method: 'get',
        headers: {
            'name':'getAwardContractDetail',
        },
        params: parameter
    })
}

// 获取当前合同的客户列表
export function getContractCustomerList (contractId) {
    return request({
        url: api.getContractCustomerList + contractId,
        method: 'get',
        headers: {
            'name':'getContractCustomerList',
        },
        params: {}
    })
}

// 设置合同所属客户
export function chooseLaborContractCustomer (parameter) {
    return request({
        url: api.chooseLaborContractCustomer,
        method: 'post',
        headers: {
            'name':'chooseLaborContractCustomer',
        },
        data: parameter
    })
}

// 获取客户业务合同列表
export function getBusinessCustomerList (parameter) {
    return request({
        url: api.getBusinessCustomerList,
        method: 'get',
        headers: {
            'name':'getBusinessCustomerList',
        },
        params: parameter
    })
}

// 客户业务创建合同
export function createBusinessContract (parameter) {
    return request({
        url: api.createBusinessContract,
        method: 'post',
        headers: {
            'name':'createBusinessContract',
        },
        data: parameter
    })
}

// 删除客户业务合同
export function deleteBusinessContract (contractId) {
    return request({
        url: api.deleteBusinessContract + contractId,
        method: 'post',
        headers: {
            'name':'deleteBusinessContract',
        },
        data: {}
    })
}

// 获取客户下的合同列表
export function getContractByCustomer (customerId,companyId) {
    return request({
        url: api.getContractByCustomer + customerId,
        method: 'get',
        headers: {
            'name':'getContractByCustomer',
        },
        params: {
            'companyId': companyId,
        }
    })
}

// 上传用户合同
export function uploadUserContract (parameter) {
    return request({
        url: api.uploadUserContract,
        method: 'post',
        headers: {
            'name':'uploadUserContract',
        },
        data: parameter
    })
}